package com.gitee.sop.websiteserver.service;

import com.alibaba.fastjson.JSONObject;
import com.gitee.sop.mongodb.MongoDTO;
import com.gitee.sop.mongodb.MongoDbResult;
import com.gitee.sop.mongodb.MongoDbUtil;
import com.gitee.sop.mongodb.MongoLike;
import com.gitee.sop.websiteserver.service.impl.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Set;

/**
 * 注册用户
 *
 * @author admin
 */
@Service
@Slf4j
public class CustomUserService extends BaseServiceImpl {
    @Resource
    private MongoDbUtil mongoDbUtil;

    @Override
    protected String getCollectionName() {
        return "portalUser";
    }

    public MongoDbResult queryPageByParam(MongoDTO mongoDTO) {
        Set<MongoLike> queryParams = mongoDTO.getQueryParams();
        Map<String, String> sortParams = mongoDTO.getSortParams();
        int current = mongoDTO.getCurrent();
        int size = mongoDTO.getSize();
        MongoDbResult mongoDbResult = mongoDbUtil.queryByParameterLike(getCollectionName(), queryParams, sortParams, current, size, JSONObject.class);
        return mongoDbResult;
    }
}
